package cn.chousensei.chousenseiblog.dto;

import lombok.Data;

import java.util.List;

@Data
public class PaginationDTO<T> {
    private List<T> data;
    private Boolean showPrevious;
    private Boolean showNext;
    private Integer page;
    private Integer totalPage;

    public void setPagination(Integer totalPage, Integer page) {

        this.totalPage = totalPage;
        this.page = page;

        //是否展示上一页
        if (!page.equals(1)) {
            showPrevious = true;
        }

        //是否展示下一页
        if (!page.equals(totalPage)) {
            showNext = true;
        }
    }
}
